//k1 edit 2022.2.9

private _center = param[0];
private _rotation = param[1];
private _static = param[2];
private _vehicle = param[3];

[_center,25] call a3e_fnc_cleanupTerrain;

_fnc_createObject = {
    params ["_className","_centerPos","_relativePos","_rotateDir","_relativeDir"];
    private ["_object", "_realPos", "_realDir"];

    _fnc_rotatePos = {
        private ["_centerPos", "_pos", "_dir"];
        private ["_px", "_py", "_mpx", "_mpy", "_ma", "_rpx", "_rpy"];
        _centerPos = _this select 0;
        _pos = _this select 1;
        _dir = _this select 2;
        _px = _pos select 0;
        _py = _pos select 1;
        _mpx = _centerPos select 0;
        _mpy = _centerPos select 1;
        _ma = _dir;
        _rpx = ( (_px - _mpx) * cos(_ma) ) + ( (_py - _mpy) * sin(_ma) ) + _mpx;
        _rpy = (-(_px - _mpx) * sin(_ma) ) + ( (_py - _mpy) * cos(_ma) ) + _mpy;
        [_rpx, _rpy, (_pos select 2)];
    };

    _realPos = ([_centerPos, [(_centerPos select 0) + (_relativePos select 0), (_centerPos select 1) + (_relativePos select 1),(_relativePos select 2)], _rotateDir] call _fnc_rotatePos);
    _object = createVehicle [_className, _realPos, [], 0, "CAN_COLLIDE"];
    _object setdir (_relativeDir + _rotateDir);
    _object setPosATL _realPos;
    _object
};

if (!isNull _vehicle) then {
	_pos = [_center,_center vectorAdd [5.3,0.9,-0.1],_rotation] call A3E_FNC_RotatePosition;
	_vehicle setDir (334 + _rotation);
	_vehicle setPosATL _pos;
}; ////

private _objs = [];
private _obj = objNull;
_obj = ['Land_ControlTower_01_F',_center,[-4.3,0,0],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_objs pushBack _obj;
_mainObj = _obj;

_obj = ['Box_NATO_Wps_F',_center,[-3.7,-1.5,12.4],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_objs pushBack _obj;
_items = [["muzzle_snds_570","muzzle_snds_H_snd_F","muzzle_snds_B_snd_F","U_B_ParadeUniform_01_US_decorated_F","U_O_ParadeUniform_01_CSAT_decorated_F","U_I_ParadeUniform_01_AAF_decorated_F","U_I_E_ParadeUniform_01_LDF_decorated_F","H_HelmetO_ViperSP_hex_F","H_ParadeDressCap_01_US_F","H_ParadeDressCap_01_CSAT_F","H_ParadeDressCap_01_AAF_F","H_ParadeDressCap_01_LDF_F","FirstAidKit"],[2,2,2,5,5,5,5,5,5,5,5,5,20]];
_weapons = [["SMG_03_TR_khaki","arifle_MSBS65_Mark_sand_F","srifle_DMR_06_hunter_khs_F","launch_B_Titan_F","MMG_01_hex_ARCO_LP_F","MMG_02_sand_RCO_LP_F"],[5,5,2,2,1,1]];
_magazines = [["50Rnd_570x28_SMG_03","30Rnd_65x39_caseless_msbs_mag","10Rnd_Mk14_762x51_Mag","Titan_AA","DemoCharge_Remote_Mag","150Rnd_93x64_Mag","130Rnd_338_Mag"],[50,50,20,10,5,3,3]];
//_backpacks = [[],[]];
clearItemCargoGlobal _obj;
clearWeaponCargoGlobal _obj;
clearMagazineCargoGlobal _obj;
clearBackpackCargoGlobal _obj;
_items params ["_arr1", "_arr2"];
{_obj addItemCargoGlobal [_arr1 select _forEachIndex, _x]} forEach _arr2;
_weapons params ["_arr1", "_arr2"];
{_obj addWeaponCargoGlobal [_arr1 select _forEachIndex, _x]} forEach _arr2;
_magazines params ["_arr1", "_arr2"];
{_obj addMagazineCargoGlobal [_arr1 select _forEachIndex, _x]} forEach _arr2;
//_backpacks params ["_arr1", "_arr2"];
//{_obj addBackpackCargoGlobal [_arr1 select _forEachIndex, _x]} forEach _arr2;

//固定武器
_MGGMH = a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_GM_H;
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-7.1,4.2,12.4],_rotation,323] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[0,-4,12.4],_rotation,133] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-7.3,-4.7,12.7],_rotation,211] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-0.3,4.3,12.4],_rotation,67] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-3.9,-2.4,9.3],_rotation,180] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-2,-2.2,6.2],_rotation,90] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-5.2,-1.4,6.2],_rotation,263] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-3.8,-2.4,3.1],_rotation,181] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-3.6,-2.5,6.2],_rotation,177] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-5.4,-1.3,9.3],_rotation,264] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-5.4,-1.6,3.1],_rotation,266] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-1.8,-2,3.1],_rotation,88] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-1.8,-1.8,9.3],_rotation,98] call _fnc_createObject;
_objs pushBack _obj;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

_campType = [_center,'哨站','神盾局'];
Escape_campType_arr pushback _campType;
publicVariable 'Escape_campType_arr';

[_mainObj,_campType] spawn {
	params ["_mainObj","_campType"];
	waitUntil {
		if (isNull _mainObj) exitWith {
			Escape_campType_arr = Escape_campType_arr - [_campType];
			publicVariable 'Escape_campType_arr';
			true
		};
		false
	};
}; //

_objs;


